package com.liuyanzhao.blog.controller.Home;

import java.util.Date;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import com.liuyanzhao.blog.entity.Link;
import com.liuyanzhao.blog.service.LinkService;

/**
 * 
 * @author jingtai sun
 *  [链接的controller]
 * @CrateTime: 2019年6月22日
 */
@Controller
public class LinkController {
	@Autowired
	private LinkService linkService;

	@RequestMapping("/applyLink")
	/**
	 * 
	 *  [ 关于申请友情链接]
	 * @return
	 * @throws Exception
	 * @Return: ModelAndView
	 * @author jingtai sun
	 * @CreateDate: 2019年6月22日 下午9:32:41
	 */
	public ModelAndView applyLinkView() throws Exception {
		ModelAndView modelAndView = new ModelAndView();
		modelAndView.setViewName("Home/Page/applyLink");
		return modelAndView;
	}


	@RequestMapping(value = "/applyLinkSubmit",method = {RequestMethod.POST})
	@ResponseBody
	public void applyLinkSubmit(Link link) throws Exception {
		link.setLinkStatus(0);
		link.setLinkCreateTime(new Date());
		link.setLinkUpdateTime(new Date());
		linkService.insertLink(link);
	}
}
